﻿using System;

namespace ConsoleApp3_Bank
{
    public class Account
    {
        private string AccountNumber;//账户信息
        private decimal Balance;//余额

        public string getAccountNumber//获取账户信息
        {
            get {return AccountNumber; }
        }

        public decimal getBalance//获取余额
        {
            get { return Balance; }
        }

        //构造函数
        public Account(string AccountNum, decimal iBalance)
        {
            AccountNumber = AccountNum;
            Balance = iBalance;
        }

        //存款
        public void Deposit(decimal amount)
        {
            if (amount > 0)
            {
                Balance += amount;
                Console.WriteLine($"本次存款数额：{amount}. 最新余额：{Balance}");
            }
            else
            {
                Console.WriteLine("错误的存款数额。");
            }
        }

        //取款
        public virtual void Withdraw(decimal amount)
        {
            if (amount > 0 && amount <= Balance)
            {
                Balance -= amount;
                Console.WriteLine($"本次取出数额：{amount}. 最新余额：{Balance}");
            }
            else
            {
                Console.WriteLine("错误的取款数额。");
            }
        }

        //显示账号信息
        public virtual void DisplayBalance()
        {
            Console.WriteLine($"账户信息：{getAccountNumber}, 余额：{getBalance}");
        }
    }

}
